package com.youyi.yyviewsdklibrary.View;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.lkx.liandianqinew.R;

public class MyPerssionView extends LinearLayout {
    private TextView mDetail;
    private TextView mName;
    private onItemClickListener mOnItemClickListener;
    private TextView mPerNo;
    private TextView mPerNormal;
    private TextView mPerYes;

    public enum ShowType {
        YES,
        NO,
        NORMAL
    }

    public interface onItemClickListener {
        void onItemClick(ShowType showType);
    }

    public MyPerssionView(Context context) {
        super(context);
    }

    public void setOnItemClickListener(onItemClickListener onitemclicklistener) {
        this.mOnItemClickListener = onitemclicklistener;
    }

    public MyPerssionView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
//        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.MyPermissionView);
//        int resourceId = obtainStyledAttributes.getResourceId(R.styleable.MyPermissionView_perSrc, R.drawable.view_close);
//        int resourceId2 = obtainStyledAttributes.getResourceId(R.styleable.MyPermissionView_perBg, R.drawable.view_cbg);
//        String string = obtainStyledAttributes.getString(R.styleable.MyPermissionView_perName);
//        String string2 = obtainStyledAttributes.getString(R.styleable.MyPermissionView_normalName);
//        String string3 = obtainStyledAttributes.getString(R.styleable.MyPermissionView_perDetail);
//        int i = 0;
//        boolean z = obtainStyledAttributes.getBoolean(R.styleable.MyPermissionView_showYes, false);
//        boolean z2 = obtainStyledAttributes.getBoolean(R.styleable.MyPermissionView_showNo, false);
//        boolean z3 = obtainStyledAttributes.getBoolean(R.styleable.MyPermissionView_showNormal, false);
//        View inflate = LayoutInflater.from(context).inflate(R.layout.view_permissiong, (ViewGroup) this, true);
//        ImageView imageView = (ImageView) inflate.findViewById(R.id.id_view_per_img);
//        this.mName = (TextView) inflate.findViewById(R.id.id_view_per_name);
//        this.mDetail = (TextView) inflate.findViewById(R.id.id_view_per_detail);
//        this.mPerYes = (TextView) inflate.findViewById(R.id.id_view_per_yes);
//        this.mPerNo = (TextView) inflate.findViewById(R.id.id_view_per_no);
//        this.mPerNormal = (TextView) inflate.findViewById(R.id.id_view_per_normal);
//        Glide.with(context).load(Integer.valueOf(resourceId)).into(imageView);
//        imageView.setBackgroundResource(resourceId2);
//        if (!TextUtils.isEmpty(string)) {
//            this.mName.setText(string);
//        }
//        if (!TextUtils.isEmpty(string2)) {
//            this.mPerNormal.setText(string2);
//        }
//        if (!TextUtils.isEmpty(string3)) {
//            this.mDetail.setVisibility(View.VISIBLE);
//            this.mDetail.setText(string3);
//        } else {
//            this.mDetail.setVisibility(View.GONE);
//        }
//        this.mPerYes.setVisibility(z ? View.VISIBLE : View.GONE);
//        this.mPerYes.setOnClickListener(new OnClickListener() {
//            /* class com.youyi.yyviewsdklibrary.View.MyPerssionView.AnonymousClass1 */
//
//            public void onClick(View view) {
//                if (MyPerssionView.this.mOnItemClickListener != null) {
//                    MyPerssionView.this.mOnItemClickListener.onItemClick(ShowType.YES);
//                }
//            }
//        });
//        this.mPerNo.setVisibility(z2 ? View.VISIBLE : View.GONE);
//        this.mPerNo.setOnClickListener(new OnClickListener() {
//            /* class com.youyi.yyviewsdklibrary.View.MyPerssionView.AnonymousClass2 */
//
//            public void onClick(View view) {
//                if (MyPerssionView.this.mOnItemClickListener != null) {
//                    MyPerssionView.this.mOnItemClickListener.onItemClick(ShowType.NO);
//                }
//            }
//        });
//        this.mPerNormal.setVisibility(!z3 ? 8 : i);
//        this.mPerNormal.setOnClickListener(new OnClickListener() {
//            /* class com.youyi.yyviewsdklibrary.View.MyPerssionView.AnonymousClass3 */
//
//            public void onClick(View view) {
//                if (MyPerssionView.this.mOnItemClickListener != null) {
//                    MyPerssionView.this.mOnItemClickListener.onItemClick(ShowType.NORMAL);
//                }
//            }
//        });
    }

    public void setTitle(String str) {
        TextView textView = this.mName;
        if (textView != null) {
            textView.setText(str);
        }
    }

    public void setDetail(String str) {
        TextView textView = this.mDetail;
        if (textView != null) {
            textView.setVisibility(View.VISIBLE);
            this.mDetail.setText(str);
        }
    }

    public void setNorMalName(String str) {
        TextView textView = this.mPerNormal;
        if (textView != null) {
            textView.setVisibility(View.VISIBLE);
            this.mPerNormal.setText(str);
        }
    }

    public void showType(ShowType showType) {
        this.mPerYes.setVisibility(View.GONE);
        this.mPerNo.setVisibility(View.GONE);
        this.mPerNormal.setVisibility(View.GONE);
        int i = showType.ordinal();
        if (i == 1) {
            this.mPerYes.setVisibility(View.VISIBLE);
        } else if (i == 2) {
            this.mPerNo.setVisibility(View.VISIBLE);
        } else if (i == 3) {
            this.mPerNormal.setVisibility(View.VISIBLE);
        }
    }
}
